package 富婆梦.第一阶段.第七周IO流;

import java.io.*;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.第七周
 * @ClassName: Redirecting
 * @Author: hemengjin
 * @Description:
 * @Date:2021/9/12 15:33
 * @Version: 1.0
 */
public class Redirecting {
    public static void main(String[] args) {

        try {
            PrintStream console = System.out;
            FileInputStream fi = new FileInputStream("D:/何梦锦的宝藏/Java学习/Redicting.txt");
            BufferedInputStream in = new BufferedInputStream(fi);

            FileOutputStream fo = new FileOutputStream("D:/何梦锦的宝藏/Java学习/test.out");
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fo);
            PrintStream out = new PrintStream(bufferedOutputStream);
            System.setIn(in);
            System.setOut(out);
            System.setErr(out);
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String s;
            while ((s = br.readLine()) != null) {
                System.out.println(s);
                out.close();
                System.setOut(console);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
